<template>
  <div class="container">
    <Content :style="{ padding: '0 10px' }">
      <Card>
        <el-alert :title="`数据一共 ${page.total}条`" type="info" show-icon> </el-alert>
        <Table :columns="columns" :data="list" :style="{margin:'20px 0 '}">
          <template slot="action" slot-scope="{ row }">
            <Button type="text" @click="prohibited(row)">{{ row.state == 0 ? '禁用' : '启用' }}</Button>
            <Button type="text" @click="addformItem(2, row)">修改</Button>
            <Button type="text" @click="deleterows(row)">删除</Button>
          </template>
        </Table>
        <Page :total="page.total" show-elevator show-sizer align="end" :style="{ padding: '20px 0 0' }" @on-change="Changepage" />
      </Card>
    </Content>
  </div>
</template>

<script>
import { list } from '@/api/example/table'
export default {
  name: 'base-logs',
  data () {
    return {
      columns: [
        {
          title: '操作类型',
          key: 'type'
        },
        {
          title: '操作人',
          key: 'author'
        },
        {
          title: '执行结果',
          key: 'title'
        },
        {
          title: '操作时间',
          key: 'display_time'
        },
        {
          title: '描述',
          key: 'forecast'
        }
      ],
      page: {
        page: 1,
        pagesize: 10,
        total: 0
      },
      list: []
    }
  },
  created () {
    this.gitlist()
  },
  methods: {
    async gitlist () {
      const { data } = await list(this.page)
      this.page.total = data.total
      this.list = data.items
    },
    Changepage (newpage) {
      this.page.page = newpage
      this.gitlist()
    }
  }
}
</script>
